<?php
class forgetController extends userController {

	public function index() {
		print_r(__ROOT__);
		$this->show();
	}

	public function data() {

		$_POST=in($_POST);
		if(empty($_POST['username'])||empty($_POST['email'])){
            $this->msg('帐号或邮箱未填写!',0);
        }
		$info=model('user_list')->user_info($_POST['username']);
		//判断
		if(empty($info)){
			$this->msg('用户名或邮箱地址输入不正确！',0);
		}

		if($info['email']<>$_POST['email']){
			$this->msg('用户名或邮箱地址输入不正确！',0);
		}
		
		//发送找回密码邮件
		model('forget')->email($info);
		$url=url('forget/success',array('username'=>$_POST['username'],'email'=>$_POST['email']));
		$this->msg($url);
	}

	public function success() {
		$data=in($_GET);
		if(empty($data['username'])||empty($data['email'])){
            $this->errorpage('您访问的页面不存在！');
        }
        $info=model('user_list')->user_info($data['username']);
        if(empty($info)){
        	$this->errorpage('您访问的页面不存在！');
        }
        if($info['email']<>$data['email']){
			$this->errorpage('您访问的页面不存在！',0);
		}
		$this->info=$info;
		$this->show();
	}


}